package com.hmdp.utils;

import com.hmdp.dto.UserDTO;


/**
 * ThreadLocal保存用户登录
 */

public class UserHolder {
    private static final ThreadLocal<UserDTO> tl = new ThreadLocal<>();

    public static void saveUserDTO(UserDTO UserDTO){
        tl.set(UserDTO);
    }

    public static UserDTO getUser(){
        return tl.get();
    }

    public static void removeUser(){
        tl.remove();
    }
}
